<#import "../tpl/pageTep.ftl" as page>
<@page.pageBase currentMenu="提现审批">
<style>
    .form-horizontal .controls {
        line-height: 42px;
    }

    .form-horizontal .time-label {
        width: 60px;
        line-height: 40px;
        margin-left: 20px;
    }

    .form-horizontal .time-controls {
        margin-left: 5px;
    }

    .form-horizontal .money-label {
        width: 60px;
        line-height: 40px;
        margin-left: 5px;
    }

    .button-primary {
        margin-left: 5px;
    }

    .form-horizontal .money-label {
        width: 60px;
    }

    .form-panel .time-input {
        width: 100px;
    }

    p {
        margin: 0;
    }
</style>
<form id="searchForm" class="form-panel">
    <ul class="panel-content" style="display: inline-block;">
        <li>
            <div class="control-group span5 " style="width:125px">
                <div class="search-controls  controls">
                    <input type="text" name="applicantName" id="title" value="" style="width:100px" placeholder="搜索关键字">
                </div>
            </div>
            <div class="form-actions span2">
                <button type="submit" class="button  button-primary">
                    搜索
                </button>
            </div>
            <div class="span10" style="width:410px">
                <label class="money-label control-label">申请日期：</label>

                <div class="time-controls controls">
                    <input name="startDate" class="input-small calendar" type="text" style="width:80px;"><span>&nbsp;--&nbsp;</span>
                    <input name="endDate" class="input-small calendar" type="text" style="width:80px;">
                </div>
                <button class="query-button button button-primary">
                    查询
                </button>
            </div>
            <label class="time-label control-label">爱心钱包：</label>

            <div class="money-controls controls">
                <input type="text" class="time-input input-normal" name="walletMoney" id="amountInput"
                       readonly="readonly" value="0"/>
            </div>
            <label class="money-label control-label">已提现：</label>

            <div class="money-controls controls">
                <input type="text" class="time-input input-normal" name="cash" id="cashInput" readonly="readonly" value="0"/>
            </div>
            <label class="money-label control-label">未提现：</label>

            <div class="money-controls controls">
                <input type="text" class="time-input input-normal" name="unCash" id="unCashInput"
                       readonly="readonly" value="0"/>
            </div>
        </li>
    </ul>
</form>
<div id="grid"></div>
<script>
    /*-------------------------------------------------------- 表格数据渲染start-----------------------------------*/
    var Grid = BUI.Grid,
            Store = BUI.Data.Store,
            columns = [
                {title: '序号', dataIndex: 'id', elCls: 'center', width: '10%'},
                {
                    title: '申请者类型',
                    dataIndex: 'applicantType',
                    elCls: 'center',
                    width: '15%',
                    renderer: function (data) {
                        if (data == "1") {
                            return '志愿者 ';
                        } else {
                            return '机构';
                        }
                    }
                },
                {
                    title: '机构名称', dataIndex: 'organizeName', elCls: 'center', width: '15%', renderer: function (data) {
                    if (data == null || data == '') {
                        return '——';
                    } else {
                        return '<p>' + data + '</p>';
                    }
                }
                },
                {title: '申请人', dataIndex: 'applicantName', elCls: 'center', width: '15%'},
                {title: '提现金额', dataIndex: 'money', elCls: 'center', width: '15%'},
                {
                    title: '状态', dataIndex: 'status', elCls: 'center', width: '15%', renderer: function (data) {
                    if (data == "1") {
                        return '待审核';
                    } else if (data == "2") {
                        return '已通过';
                    } else if (data == "3") {
                        return '不通过';
                    } else {
                    }
                }
                },
                {
                    title: '操作', dataIndex: 'id', elCls: 'center', width: '15%', renderer: function (value, data) {
                    if (data.status == "1") {
                        return '<a href="${basepath}/manage/wallet/toCheckEdit?id=' + value + '">审核</a>';
                    } else if (data.status == "2") {
                        return '<a href="${basepath}/manage/wallet/toDetail?id=' + value + '">查看</a> ';
                    } else if (data.status == "3") {
                        return '<a href="${basepath}/manage/wallet/toDetail?id=' + value + '">查看</a>';
                    } else {
                    }
                }
                }
            ];
    var store = new Store({
                url: 'loadData',
                autoLoad: true, //自动加载数据
                params: { //配置初始请求的参数
                    length: '10',
                    status: $("#phone").val()
                },
                pageSize: 10,	// 配置分页数目
                root: 'list',
                totalProperty: 'total'
            }),
            grid = new Grid.Grid({
                render: '#grid',
                columns: columns,
                loadMask: true, //加载数据时显示屏蔽层
                store: store,
                plugins: [Grid.Plugins.CheckSelection], // 插件形式引入多选表格

                // 底部工具栏
                bbar: {
                    pagingBar: true
                }
            });
    grid.render();

    var form = new BUI.Form.HForm({
        srcNode: '#searchForm'
    }).render();

    form.on('beforesubmit', function (ev) {
        //序列化成对象
        var obj = form.serializeToObject();
        obj.start = 0; //返回第一页
        store.load(obj);
        return false;
    });
    /*-------------------------------------------------------- 表格数据渲染end-----------------------------------*/

    //查询爱心钱包总数、已提现、未提现的值

    //查询爱心钱包总数
    $.ajax({
        type: "GET",
        url: "${basepath}/manage/brokerage/selectNotAdminSum",
        dataType: "json",
        success: function (data) {
            var walletMoney = data.data;
            $("#amountInput").val(walletMoney);
        }
    })
    //查询已提现
    $.ajax({
        type: "GET",
        url: "${basepath}/manage/wallet/selectCashSum",
        dataType: "json",
        success: function (data) {
            var cash = data.data;
            $("#cashInput").val(cash);
        }
    })
    //查询未提现
    $.ajax({
        type: "GET",
        url: "${basepath}/manage/wallet/selectUnCashSum",
        dataType: "json",
        success: function (data) {
            var unCash = data.data;
            $("#unCashInput").val(unCash);
        }
    })


</script>
</@page.pageBase>